function PopUpWidthHeight(hyperlink,width,height)
{
	var now = new Date();
	window.open($(hyperlink).attr('href'),now.getSeconds(),"left=200,top=200,height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}

function PopUpWidthHeightWithScroll(hyperlink,width,height)
{
	var now = new Date();
	window.open( jQuery(hyperlink).attr('href'),now.getSeconds(),"left=200,top=200,height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes");
    return false;
}

function PopUp(hyperlink)
{
	var now = new Date();
	window.open( jQuery(hyperlink).attr('href'),now.getSeconds(),"left=200,top=200,height=720,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}


function PopUpScroll(hyperlink)
{
	var now = new Date();
	window.open( jQuery(hyperlink).attr('href'),now.getSeconds(),"left=200,top=200,height=650,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes");
    return false;
}

function PopUpWidthHeight(hyperlink,width,height)
{
	var now = new Date();
	window.open( jQuery(hyperlink).attr('href'),now.getSeconds(),"left=200,top=200,height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}

function PopUpLink(hyperlink)
{
	var now = new Date();
	window.open( hyperlink,now.getSeconds(),"left=200,top=200,height=650,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}

function PopUpLinkScroll(hyperlink)
{
	window.open( hyperlink,null,"left=200,top=200,height=650,width=850,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes");
    return false;
}

function PopUpLinkWidthHeight(hyperlink,width,height)
{
	var now = new Date();
	window.open( hyperlink,null,"left=200,top=200,height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}
/**********************************************************************/
//�rn: Kredi kartlarinda 4 haneli numaralar arasinda gecis icin yapilmistir
//		Telefon no alan adlari icin eklendi
/**********************************************************************/
function focusNextOrPrev(textInput, maxLength, firstElementId) {
	var length = jQuery(textInput).val().length;

	if (length == maxLength)
		jQuery(textInput).next().focus();
	else if (length == 0 && !(jQuery(textInput).attr("id") == firstElementId)){
		jQuery(textInput).prev().focus();
		//explorer icin---> focus olunca en basa gidiyordu,textin en sonunda olmasi icin
		jQuery(textInput).prev().val(jQuery(textInput).prev().val());
	}
	return true;
}

function isValidEmail(email)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if(!filter.test(email))
		return false;

	return true;
}

function isValidEmailAllEmailString(emailSt)
{
	var arrayOfEmail = emailSt.split(",");
	var result = true;

	for(var i=0; i<arrayOfEmail.length; i++ )
	{
		if(!isValidEmail(trim(arrayOfEmail[i])))
		{
			result = false;
			break;
		}
	}

	if(result)
	{
		return result;
	}
	else
	{
		result = true;
		arrayOfEmail = emailSt.split(";");
		for(i=0; i<arrayOfEmail.length; i++ )
		{
			if(!isValidEmail(trim(arrayOfEmail[i])))
			{
				result = false;
				break;
			}
		}
	}

	return result;
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++)
 {
   	Char = sText.charAt(i);
   	if (ValidChars.indexOf(Char) == -1)
      {
      	IsNumber = false;
      }
  }
	return IsNumber;
}

function isChar( str ) {
  valid = true;

	if(str == "" || str == "null" || str =="undefined")
	{
		return true;
	}

	for(var i = 0; i < str.length; i++)
	{
		if(str.charAt(i) >= "0" && str.charAt(i) <= "9")
	 	{
  		valid = false;
  		break;
  	}
	}
	return valid;
}

function isLetter (c)
{
return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || c=="ı" || c=="ş" || c=="ğ" || c=="Ğ" || c=="ü" ||c=="Ü" ||c=="Ş" ||c=="İ" ||c=="ö" ||c=="Ö" ||c=="ç" ||c=="Ç");
}


function isTekrarlayan(deger)
{
	sonuc = true;
	i=0;
	k=1;
	while (i<deger.length)
	{
		if (deger.charAt(i) == deger.charAt(k))
 	{
   		i=i+1;
   		k=k+1;
 	}
		else
    		sonuc = false;

    	break;
	}
	return sonuc;
}

function isArdisik(sayi)
{
	i=0;
	k=1;
	sonuc = true;
	while (i<sayi.length-1)
	{
		birinci = parseInt(sayi.charAt(i));
		ikinci = parseInt(sayi.charAt(k));
		if (birinci + 1 == ikinci)
 	{
   		i=i+1;
   		k=k+1;
   		continue;
 	}
		else
		{
    		sonuc = false;
    		break;
    	}
	}
	if (!sonuc)
	{
		sonuc = true;
		i=0;
		k=1;
		while (i<sayi.length-1)
		{
			birinci = parseInt(sayi.charAt(i));
			ikinci = parseInt(sayi.charAt(k));
			if (birinci - 1 == ikinci)
			{
				i=i+1;
				k=k+1;
				continue;
			}
			else
			{
    			sonuc = false;
    			break;
    		}
		}
	}
return sonuc;
}
function trim(stringToTrim)
{
	if(stringToTrim == undefined)
		return stringToTrim;
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function checkLength(attribute, len){
 if (attribute.length != len){
    return false;
 }
	return true;
}

function MaskMoneyToDouble(myvalue)
{
	var d;
	d = myvalue.replace(/(\.)/g,"");
	d = d.replace(/,/g,"\.");
	return parseFloat(d);
	/*
	var result = d * 1;
	return 	result;
	*/
}

function checkDigitTcKimlikNo(tcKimlikNo)
			{
				var Arr  = new Array(0,0,0,0,0,0,0,0,0);
				var tmp1;
				var tmp;
				var odd_sum;
				var even_sum;
				var total;
				var chkdigit2;
				var chkdigit1;
				tmp  = Math.floor(tcKimlikNo  / 100);
				tmp1 = Math.floor(tcKimlikNo  / 100);
  			for (i = 8; i >= 0; )
  			{
					Arr[i] = tmp1 % 10;
					tmp1 = Math.floor(tmp1 / 10);
					i = i-1;
  			}
 			odd_sum   = Arr[8] + Arr[6] + Arr[4] + Arr[2] + Arr[0];
 			even_sum  = Arr[7] + Arr[5] + Arr[3] + Arr[1];
 			total     = odd_sum * 3 + even_sum;
 			chkdigit1 = (10 -(total % 10)) % 10;
 			odd_sum   = chkdigit1 + Arr[7] + Arr[5] + Arr[3] + Arr[1];
 			even_sum  = Arr[8] + Arr[6] + Arr[4] + Arr[2] + Arr[0];
 			total     = odd_sum * 3 + even_sum;
 			chkdigit2 = (10 -(total % 10)) % 10;
 			tmp       = tmp * 100 + chkdigit1 * 10 + chkdigit2;

 			if (tmp != tcKimlikNo)
 			{
					return false;
 			}
 			return true;
			}

var MONTH_NAMES=new Array('');
var DAY_NAMES=new Array('');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}


function tarihKarsilastir(firstDate,secondDate)
{
	if(firstDate.getFullYear() > secondDate.getFullYear())
		return 1;
	if(firstDate.getFullYear() < secondDate.getFullYear())
		return -1;

	if(firstDate.getMonth() > secondDate.getMonth())
		return 1;
	if(firstDate.getMonth() < secondDate.getMonth())
		return -1;

	if(firstDate.getDate() > secondDate.getDate())
		return 1;
	if(firstDate.getDate() < secondDate.getDate())
		return -1;

	return 0;
}

function stringToDate(dateString,format)
{
	var myDateParts = dateString.split("/");
	myJSDate = new Date(myDateParts[2], (myDateParts[1]-1), myDateParts[0]);
	return myJSDate;
}

function dateToString(dateDate,format)
{
	return formatDate(dateDate,format);
}

function showAlert(message){
	alert(message);
}

function is2denFazlaTekrarlayan(el){
	var pwd = el.split("");
		for( var n=0; n<pwd.length-2; n++){
		    if(pwd[n]==pwd[n+1] && pwd[n+1]==pwd[n+2]){
		      n=0;
		      break;
	    }
	  }

	if(n<pwd.length-2){
	    return false;
	}
	return true;
}
function is5iAynimi(el){
	var pwd = el.split("");
		for( var n=0; n<pwd.length-2; n++){
		    if(pwd[n]==pwd[n+1] && pwd[n+1]==pwd[n+2] && pwd[n+2]==pwd[n+3] && pwd[n+3]==pwd[n+4]){
		      n=0;
		      break;
	    }
	  }

	if(n<pwd.length-2){
	    return false;
	}
	return true;
}

function allowNumeric(e) {
	e=e||window.event;
	var k=e.charCode||e.keyCode||e.which;
	if (k == 8) {
		return true;
	} else if (k == 9) {
		return true;
	} else if (k < 48 || k > 57) {
		return false;
	}
	return true;
}

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer(){
    // Set the length of the timer, in seconds
    if(enableTimer){
	    secs = 60 * 10; //5 min. 5 * 60 secs.
	    StopTheClock();
	    StartTheTimer();
    }
}

function StopTheClock(){
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer(){
	//özelliikle -5 yaptık, popup tan aksiyon gelmesine izin verelim.
	//popup blocker varsa bu devreye girsin.
    if (secs == -5){
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        logout();
	}else{
	    if (secs == 60){
	        popupTimeout();
	   	}
	   	secs = secs - 1;
	   	timerRunning = true;
	   	timerID = self.setTimeout("StartTheTimer()", delay);
	}
}
function getSecs(){
	return secs;
}
function logout(){
	window.location.href = '/EposWeb/Logout.jsf';
}
function popupTimeout(){
	openTimeoutWin("/EposWeb/includes/PopupTimeout.jsf") ;
}
function openTimeoutWin(hyperlink)
{
	var now = new Date();
	window.open( hyperlink,now.getSeconds(),"left=200,top=200,height=300,width=550,status=no,toolbar=no,menubar=no,location=no,resizable=no");
    return false;
}
function refreshTimeout(){
	InitializeTimer();
}
jQuery(document).ready(function() {
	InitializeTimer();
});

